package com.algorithm.arraylist;

/**
 * @author xiwai [hww282306@alibaba-inc.com]
 * @version 1.0
 * @date 2020/9/28 4:10 下午
 */
public class MyArrayListTest {

    public static void main(String[] args) {
//        testAddAndGet();
//        testSet();
        testRemove();
    }

    static void testAddAndGet() {
        MyArrayList<String> list = new MyArrayList<>();
        list.add("Tom");
        list.add("Bob");
        System.out.println(list.get(0));
        System.out.println(list.get(1));
    }

    static void testSet() {
        MyArrayList<String> list = new MyArrayList<>();
        list.add("Tom");
        list.add("Bob");
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        list.set(1, "John");
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        try {
            list.set(2, "Mike");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("ArrayIndexOutOfBoundsException");
        }
    }


    static void testRemove() {
        MyArrayList<String> list = new MyArrayList<>();
        list.add("Tom");
        list.add("Bob");
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        list.remove("Tom");
        System.out.println(list.get(0));
        list.remove(0);
        System.out.println(list.size());
    }




}
